package main.scala

object AST {
  
	import org.kiama.attribution.Attributable
	import scala.util.parsing.input.Positional

	type Idn = String
	trait Tree extends Attributable with Positional
	
	sealed abstract class Exp extends Tree
	
    /**
     * Terminals cannot be simplified further.
     */
    trait Terminal
    
	trait Numeric extends Exp with Terminal

	case class NumI(v: Int) extends Numeric
	case class NumD(v: Double) extends Numeric
	case class Var (name : Idn) extends Exp with Terminal

	
	abstract class UnaryOp(e : Exp) extends Exp
	
	case class Neg (e : Exp) extends UnaryOp (e)
	
	abstract class BinaryOp (l : Exp, r : Exp) extends Exp 

	/* Binary operators used in the parser and output ASTs */
	case class BAdd (l : Exp, r : Exp) extends BinaryOp (l, r)
	case class BSub (l : Exp, r : Exp) extends BinaryOp (l, r)
	case class BMul (l : Exp, r : Exp) extends BinaryOp (l, r)
	case class BDiv (l : Exp, r : Exp) extends BinaryOp (l, r)

	/* The following operators are common to both ASTs. */
	case class Pow (l : Exp, r : Exp) extends BinaryOp (l, r)
	case class Mod (l : Exp, r : Exp) extends BinaryOp (l, r)
	
	/* List operators used in the internal representation */
	/* Add and Mul are symmetric operators. */
	case class Add (terms : List[Exp]) extends Exp
	case class Mul (terms : List[Exp]) extends Exp
	
//	abstract class Stmt extends Exp{
//	  //def vars: Set[Exp]
//	 // def vars : Set[Idn] = Set ()
//	}
//	
//	case class Null () extends Stmt
//	
//	case class Seqn (ss : Seq[Exp]) extends Stmt {
//	 // override def vars = Set (ss flatMap (_ vars) : _*)
//    }
//    case class Asgn (v : Var, e : Exp) extends Stmt {
//    //  override def vars = Set (v.s)
//    }



}